﻿using Com.Enemy.EnemySystem.EnemyLifecycle;
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.TextCore.LowLevel;

public class EnemyBuffManager
{
    public Dictionary<string,EnemyBuff> buffs { get; } = new Dictionary<string, EnemyBuff>();
    
    EnemyBody enemyBody;

    public void GetBuff(EnemyBuff buff)
    {
        if (buffs.ContainsKey(buff.Name))
        {
            buffs[buff.Name].Get_Second();
        }
        else
        {
            buffs.Add(buff.Name, buff);
            buff.Start(enemyBody);
        }
        
    }

    public void RemoveBuff(EnemyBuff buff)
    {
        buff.OnEnd();
        buffs.Remove(buff.Name);
    }

    private void OnDestroy()
    {
        foreach (var item in buffs.Keys)
        {
            buffs[item].OnEnd();
        }
        buffs.Clear();
    }

    
}
